//
//  DCDownloadOpration.h
//  DCDownloadOpration
//
//  Created by collegepre on 16/4/1.
//  Copyright © 2016年 Wade. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "DCDownloadConst.h"

@class DCDownloadOpration;
/**
 *  下载进度发生改变的时候回调的block
 *
 *  @param curentBytes 当前下载的字节数
 *  @param TotalBytes  总字节数
 *  @param progress    下载进度的%比
 */
typedef void (^DCDownloadOprationResuming)(NSInteger curentBytes,NSInteger TotalBytes,DCDownloadOpration *downloadopration);

/**
 *  下载任务完成回调的block
 */
typedef void(^DCDownloadOprationComplition)(DCDownloadOpration *downloadopration);

/**
 *  下载任务失败回调的block
 *
 *  @param error 错误信息
 */
typedef void(^DCDownloadOprationError)(NSError *error,DCDownloadOpration *downloadopration);

/**
 *  状态改变的Block回调
 *
 *  @param file 文件的下载路径  预留处理失败时候删除错误包
 *  @param error    失败的描述信息
 */
typedef void (^DCDownloadStateChangeBlock)(DCDownloadState state, NSString *file, NSError *error,DCDownloadOpration *downloadopration);

@interface DCDownloadOpration : NSObject

/** 下载状态 */
@property (assign, nonatomic) DCDownloadState state;

/** 文件名 */
@property (copy, nonatomic) NSString *destinationPath;

/** 文件url */
@property (copy, nonatomic) NSString *url;


/**
 *  下载完成回调
 */
@property (nonatomic, copy) DCDownloadOprationComplition downloadComplitionBlock;
/**
 *  下载错误回调
 */
@property (nonatomic, copy) DCDownloadOprationError downloadErrorBlock;
/**
 *  下载状态发生改变的时候回调
 */
@property (nonatomic, copy) DCDownloadStateChangeBlock downloadStateChangeBlock;
/**
 *  正在下载的时候回调
 */
@property (nonatomic, copy) DCDownloadOprationResuming downloadResumingBlock;

//- (void)setUrlStr:(NSString *)urlstl;
/**
 *  状态改变发送通知
 */
- (void)notifyStateChange;

/**
 *  下载进度发生改变发送的通知
 */
- (void)notifyProgressChange;

/**
 *  设置下载seesion
 *
 *  @param session 
 */
- (void)setupTask:(NSURLSession *)session;
/**
 *  接受下载数据
 *
 *  @param data
 */
- (void)didReceiveData:(NSData *)data;

- (void)didReceiveResponse:(NSHTTPURLResponse *)response;

- (void)didCompleteWithError:(NSError *)error;

/**
 *  取消
 */
- (void)cancel;
/**
 *  恢复
 */
- (void)resume;

/**
 * 等待下载
 */
- (void)willResume;
/**
 *  暂停
 */
- (void)suspend;

@end
